<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="/tld/flowdictionary" prefix="flowdictionary"%>
<%@ taglib uri="/tld/dictionary" prefix="dictionary"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link rel="stylesheet" href="${ctx}/static/css/style.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/style1.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/kongjian.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/jquery.ui.all.css" />
<script src="${ctx}/static/script/jquery-1.4.min.js" type="text/javascript"></script>
<script src="${ctx}/static/script/jquery.ui.core.js"></script>
<script src="${ctx}/static/script/jquery.ui.datepicker.js"></script>
<script type="text/javascript" src="${ctx}/static/script/jquery.blockUI.js"></script>
 <title>交易单管理</title>
<script language="JavaScript">
	$(function() {
		$(".date-pick" ).datepicker({
	      dateFormat:'yy-mm-dd',
	      selectOtherMonths:true,
	      changeYear: true
  		});
	});
</script>
<script language="javascript">
//收付款提交操作
function submit_(orderId,vAction){
	var thisform = document.getElementById('mainForm');
	thisform.action=vAction;
	thisform.id.value=orderId;
	document.getElementById('pageNo').value = 1;
	thisform.submit();
}

$(document).ajaxStop($.unblockUI); 
function replyOrder(orderId){
	var isTrue = confirm('确定要撤单吗？');
	if(isTrue==false){
		return ;
	}
	$.blockUI({ message: '<div><img src="${ctx}/static/images/busy.gif" /><font size="4px"> Just a moment...</font></div>' }); 
	$.get("${ctx}/order/reply_order?orderId="+orderId, function(data) {
		if(data.errorMsg!=null){
			alert(data.errorMsg);
		}
		var thisform = document.getElementById('mainForm');
		thisform.submit();
	});
}
</script>
</head>

<body>
<form:form id="mainForm" action="${ctx}/order/tradeOrders" modelAttribute="recommendInfoForm" method="post">
  <input type="hidden" name="id" id="id" value="${orderForm.id}"/>

<div class="er_banner">交易单管理</div>
   <div class="shenqing2">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
	      <tr>
            <td width="61">客户编号：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" id="customerCode" name="investInfo.customerInfo.customerCode" class="ggkj_inputtext_80" value="${recommendInfoForm.investInfo.customerInfo.customerCode}" /></td>
            <td width="85">客户姓名：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" id="loanCustomerName" name="loanCustomerName"  class="ggkj_inputtext_80" value="${recommendInfoForm.loanCustomerName}" />
            </td>
			<td width="85">投资编号：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" id="investId" name="investId" class="ggkj_inputtext_80" value="${recommendInfoForm.investId}" />
            </td>
			<td width="85">交易单编号：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" id="orderId" name="orderId" class="ggkj_inputtext_80" value="${recommendInfoForm.orderId}" />
			 <td width="93"><input name="Input" type="submit" class="chaxun_btn" value="&nbsp;&nbsp;查询" />
             </td>
          </tr>
      </table>
    </div>
<div class="yiban">
	<table style="width:100%;" class="ggkj_table"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col">序号</th>
    <th scope="col">交易单编号</th>
    <th scope="col">客户编号</th>
    <th scope="col">投资编号</th>
    <th scope="col">购买人姓名</th>
    <th scope="col">约定交割日</th>
    <th scope="col">交易单金额</th>
    <th scope="col">已付款金额</th>
    <th scope="col">应付剩余金额</th>
	<th scope="col">状态</th>
    <th scope="col">操作</th>
  </tr>
  	<c:forEach items="${page.result}" var="item" varStatus="stauts">
  			<c:if test="${stauts.count%2==0}">
  				<tr class="ggkj_tdColr">
  			</c:if>
  			<c:if test="${stauts.count%2!=0}">
  				<tr >
  			</c:if>
		  <td>${stauts.count+(page.pageNo-1)*10}</td>
		  <td>${item.id}</td>
		  <td>${item.investInfo.customerInfo.customerCode}</td>
		  <td>${item.investInfo.id}</td>
		  <td><a href="#" onclick="submit_('${item.id}','${ctx}/recommend/select_order_detail')">${item.investInfo.customerInfo.cnName}</a></td>
		  <td>
		  <fmt:formatDate value="${item.appointPaymentDate}"   pattern="yyyy-MM-dd" type="date" dateStyle="long" />
		  </td>
		  <td><fmt:formatNumber value="${item.orderAmt}" pattern="##,###.##" /></td>
		  <td><fmt:formatNumber value="${item.paymentAmt}" pattern="##,###.##" /></td>
		  <td>
		  <fmt:formatNumber value="${item.orderAmt-item.paymentAmt}" pattern="##,###.##" />
		  </td>
		  <td>
		  	<flowdictionary:display code="${item.flowId}" />
		  </td>
		  <td> <!-- ${item.investInfo.flowId}||${item.investInfo.regularType}||${item.flowId}||${item.payType}|| -->
		  		<c:if test="${item.investInfo.flowId<02000008}"><!-- 非回款订单 -->
			  		<c:if test="${item.flowId=='03000005'}">
				  		<a href="#" onclick="replyOrder(${item.id});">撤单</a>
					  |<a href="#" onclick="submit_('${item.id}','${ctx}/order/order_pay')" >付款</a>
					  |收款
				  	</c:if>
			  		<c:if test="${item.flowId=='03000007'}">
				  		撤单
					  |<a href="#" onclick="submit_('${item.id}','${ctx}/order/order_pay')" >付款</a>
					  |收款
				  	</c:if>
			  		<c:if test="${item.flowId=='03000008'}">
				  		撤单
					  |付款
					  |<a href="#" onclick="submit_('${item.id}','${ctx}/order/order_receivables_init')">收款</a>
				  	</c:if>
			  		<c:if test="${item.flowId=='03000009' || item.flowId=='03000010'}">
				  		撤单
					  |付款
					  |收款
				  	</c:if>
			  	</c:if>
			  	<c:if test="${item.investInfo.flowId>=02000008}"><!-- 回款订单 -->
			  		<c:if test="${item.investInfo.regularType!=null && item.investInfo.regularType=='00130002'}"><!-- 定投回款 -->
					  		<c:if test="${item.payType=='01'}">
						  		<c:if test="${item.flowId=='03000005'}">
							  		<a href="#" onclick="replyOrder(${item.id});">撤单</a>
								  |<a href="#" onclick="submit_('${item.id}','${ctx}/order/order_pay')" >付款</a>
								  |收款
							  	</c:if>
						  		<c:if test="${item.flowId=='03000007' || item.flowId=='03000008'|| item.flowId=='03000009' || item.flowId=='03000010'}">
							  		撤单
								  |付款
								  |收款
							  	</c:if>
					  		</c:if>
					  		<c:if test="${item.payType=='03'}">
						  		<c:if test="${item.flowId=='03000005' ||item.flowId=='03000007' || item.flowId=='03000008'|| item.flowId=='03000009' || item.flowId=='03000010'}">
							  		撤单
								  |付款
								  |收款
							  	</c:if>
					  		</c:if>
					</c:if>
					<c:if test="${item.investInfo.regularType!=null && item.investInfo.regularType=='00130001'}"><!-- 定投回款 -->
							  	<c:if test="${item.flowId=='03000005' ||item.flowId=='03000007' || item.flowId=='03000008'|| item.flowId=='03000009' || item.flowId=='03000010'}">
							  		撤单
								  |付款
								  |收款
							  	</c:if>
					</c:if>
  				</c:if>
		  </td>
	  </tr>
	</c:forEach>

</table>
	
</div>
<div class="ggkj_pagecontainer">
  <div class="ggkj_pageBGleft">
    	<span class="ggkj_pageBGright"></span>
    	<a href="javascript:jumpPage(1)" class="ggkj_pageUpa">
        
        </a>
        <a href="javascript:jumpPage(${page.prePage})" class="ggkj_pageUp">
        
        </a>
        <span class="ggkj_insertline"></span>
        <span class="ggkj_pageSpan">
        	页<input type="text" id="pageNo" name="pageNo" class="ggkj_inputtext_30" value="${page.pageNo}">OF ${page.totalPages}
        </span>
        <span class="ggkj_insertline"></span>
        <a href="javascript:jumpPage(${page.nextPage})" class="ggkj_pageDown">
        
        </a>
        <a href="javascript:jumpPage(${page.totalPages})" class="ggkj_pageDowna">
        
        </a>
        <span class="ggkj_insertline"></span>
        
    </div>
</div>
<script language="JavaScript">
function jumpPage(pageNo) {
	document.getElementById('pageNo').value=pageNo;
	document.getElementById('mainForm').submit();
}

  function OpenMatchWindow()
  {
   	window.showModalDialog("${ctx}/fortune/transmatch",window,"dialogWidth:400px;status:no;dialogHeight:250px"); 
  }
</script>
</form:form>
</body>
</html>
